package com.hiyiin.IntelligentHospital.cmn.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.hiyiin.IntelligentHospital.cmn.dao.DictDao;
import com.hiyiin.IntelligentHospital.model.cmn.Dict;
import com.hiyiin.IntelligentHospital.vo.cmn.DictEeVo;
import org.springframework.beans.BeanUtils;
import org.springframework.context.annotation.Bean;

public class DictListener extends AnalysisEventListener<DictEeVo> {
    private DictDao dictDao;

    //构造方法注入
    public DictListener(DictDao dictDao){
        this.dictDao = dictDao;
    }

    @Override
    public void invoke(DictEeVo dictEeVo, AnalysisContext analysisContext) {
        //调用方法添加数据库
        Dict dict = new Dict();
        BeanUtils.copyProperties(dictEeVo, dict);
        dictDao.insert(dict);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
